package File;

import java.io.File;
import java.io.FileFilter;

public class ListFilesDemo3 {
    public static void main(String[] args) {
        File file = new File(".");
        if (file.isDirectory()) {
            File[] sub = file.listFiles(new FileFilter() {
                @Override
                public boolean accept(File file) {
                    return file.getName().endsWith(".txt");
                }
            });

        }
    }
}